<template>
  <div>
<h2>登录</h2>
<table class="table table-bordered">
  <tbody>
      <tr>
        <td>账号</td>
        <td><input type="text" v-model="state.Name"></td>
      </tr>
      <tr>
        <td>秘密</td>
        <td><input type="password" v-model="state.Pwd"></td>
      </tr>
      <tr>
        <td></td>
        <td><input type="button" value=" 登录" @click="log"></td>
      </tr>
  </tbody>
</table>
  </div>
</template>

<script setup lang="ts">

import { reactive,toRefs,onMounted } from 'vue';
import axios from 'axios';
import { useRoute,useRouter } from 'vue-router';

const route=useRoute();
const router=useRouter();

let data:any=reactive({
  state:{
    Name:'',
    Pwd:''
  } 
})

let {state}=toRefs(data);

const log=()=>{
  let obj={
    Name:state.value.Name,
    Pwd:state.value.Pwd,
  }
  axios({
    url:'/api/one/log',
    method:'get',
    params:obj
  }).then((res)=>{
    console.log(res)
    if(res.data.data>0){
        alert('成功');
        router.push('/show')
        return;
    }
    else
    {
      alert('失败');
      return;
    }
  }).catch((err)=>{
    console.log(err)
  })
}


</script>

<style scoped>

</style>